//插入排序
#include <iostream>
#include "rrand.h"
using namespace std;
void InsertionSort(int *arr,int len){
    for(int j=1;j<len;j++){
        int key=arr[j];
        int i=j-1;
        while (i>=0 && arr[i]>key)
        {
            arr[i+1]=arr[i];
            i--;
        }
        arr[i+1]=key;
    }
}
int main()
{
    int arr[20];
    int len=sizeof(arr)/sizeof(arr[0]);
    rrand(arr,len,1);
    for(int i=0;i<len;i++){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    InsertionSort(arr,len);
    for(int i=0;i<len;i++){
        cout<<arr[i]<<" ";
    }
    return 0;
}